<template>
  <div class="bg-white rounded-lg p-5 h-full flex flex-col">
    <div class="font-bold text-xl mb-4">{{ hospitalInfo.enterpriseName }}</div>
    <div class="mb-4">医疗卫生</div>
    <div class="">
      <el-descriptions :column="2" border>
        <el-descriptions-item label="所在镇/街道" span="2">
          {{ hospitalInfo.town }}
        </el-descriptions-item>
        <el-descriptions-item label="详细地址" span="2">
          {{ hospitalInfo.addr }}
        </el-descriptions-item>
        <el-descriptions-item label="医生人数">
          {{ hospitalInfo.physicianNum }}
        </el-descriptions-item>
        <el-descriptions-item label="护士人数">
          {{ hospitalInfo.nurseNum }}
        </el-descriptions-item>
      </el-descriptions>
      <div class="font-bold my-4">医疗废弃物处置记录</div>

      <el-form :model="queryForm" ref="queryForm" size="small" :inline="true">
        <el-form-item prop="dateRange">
          <el-date-picker
            v-model="queryForm.dateRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>
        <el-form-item prop="handelType">
          <el-select
            v-model="queryForm.handelType"
            placeholder="处置类型"
            style="width: 100%"
          >
            <el-option
              v-for="item in dict.type.waste_manage_type"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="handelName">
          <el-input
            v-model="queryForm.handelName"
            placeholder="处置人"
            clearable
            @keyup.enter.native="search"
          />
        </el-form-item>
      </el-form>
      <div class="mb-4">
        <el-button type="primary" @click="search">查询</el-button>
        <el-button @click="reset">重置</el-button>
      </div>
      <el-table :data="dataList" border>
        <el-table-column prop="handelTime" label="处置时间" min-width="100">
        </el-table-column>

        <el-table-column prop="handelName" label="处置人" min-width="100">
        </el-table-column>
        <el-table-column prop="handelStatus" label="状态" min-width="100">
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.waste_manage_status"
              :value="scope.row.handelStatus"
            />
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="100">
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="toDetailPage(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <hr class="my-4" />
    <div class="">
      <el-button type="primary" @click="goBack">返回</el-button>
    </div>
  </div>
</template>

<script>
import { getWasteDisposalListAPI } from "@/api/zhangping/health-care/waste-disposal";
export default {
  dicts: ["waste_manage_status", "waste_manage_type"],
  data() {
    return {
      queryForm: {
        pageNum: 1,
        pageSize: 10,
        creditCode: this.$store.state.hospital.info.creditCode,
        dateRange: null,
        handelName: null,
        handelType: null,

        params: {
          beginHandelTime: null,
          endHandelTime: null,
        },
      },
      loading: false,
    
      dataList: [],
    };
  },
  computed: {
    hospitalInfo() {
      return this.$store.state.hospital.info; 
    }
  },
  mounted() {
    this.getDataList();
  },
  methods: {
    toDetailPage(row) {
      const obj = {
        path: "/health-care/waste-disposal-detail",
        query: {
          id: row.id,
        },
      };
      this.$router.push(obj);
    },
    reset() {
      this.$refs["queryForm"].resetFields();
      this.queryForm.dateRange = null 
      this.search();
    },
    search() {
      this.queryForm.pageNum = 1;
      this.getDataList();
    },
    goBack() {
      this.$router.back();
    },
    getDataList() {
      this.loading = true;
      const { dateRange } = this.queryForm;
      this.queryForm.params.beginHandelTime = dateRange ? dateRange[0] : null;
      this.queryForm.params.endHandelTime = dateRange ? dateRange[1] : null;
      getWasteDisposalListAPI(this.queryForm)
        .then((response) => {
          this.dataList = response.rows;
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
